package com.ruoyi.business.controller;

import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.DisplayVideo;
import com.ruoyi.business.service.IDisplayVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 是否展示视频Controller
 * 
 * @author lcz
 * @date 2025-02-27
 */
@Api(tags = "是否展示视频相关接口")
@RestController
@RequestMapping("/business/displayVideo")
public class DisplayVideoController extends BaseController
{
    @Autowired
    private IDisplayVideoService displayVideoService;

    /**
     * 查询是否展示视频列表
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:displayVideo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DisplayVideo displayVideo)
    {
        startPage();
        List<DisplayVideo> list = displayVideoService.selectDisplayVideoList(displayVideo);
        return getDataTable(list);
    }

    /**
     * 导出是否展示视频列表
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:displayVideo:export')")
    @Log(title = "是否展示视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DisplayVideo displayVideo)
    {
        List<DisplayVideo> list = displayVideoService.selectDisplayVideoList(displayVideo);
        ExcelUtil<DisplayVideo> util = new ExcelUtil<DisplayVideo>(DisplayVideo.class);
        util.exportExcel(response, list, "是否展示视频数据");
    }

    /**
     * 获取是否展示视频详细信息
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:displayVideo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(displayVideoService.selectDisplayVideoById(id));
    }

    /**
     * 新增是否展示视频
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:displayVideo:add')")
    @Log(title = "是否展示视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DisplayVideo displayVideo)
    {
        return toAjax(displayVideoService.insertDisplayVideo(displayVideo));
    }

    /**
     * 修改是否展示视频
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:displayVideo:edit')")
    @Log(title = "是否展示视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DisplayVideo displayVideo)
    {
        return toAjax(displayVideoService.updateDisplayVideo(displayVideo));
    }

    /**
     * 删除是否展示视频
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:displayVideo:remove')")
    @Log(title = "是否展示视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(displayVideoService.deleteDisplayVideoByIds(ids));
    }

    /** 前端接口 ***************************************************************************************************/
    /** 前端接口 ***************************************************************************************************/
    /** 前端接口 ***************************************************************************************************/

    /**
     * 查询是否展示视频列表
     * 接口路径：/displayVideo/front/list
     */
    @GetMapping("/front/list")
    @ApiOperation("前台查询是否展示视频列表")
    public TableDataInfo<DisplayVideo> frontList(DisplayVideo displayVideo)
    {
        startPage();
        List<DisplayVideo> list = displayVideoService.selectDisplayVideoList(displayVideo);
        return getDataTable(list);
    }

    /**
     * 获取是否展示视频详细信息
     * 接口路径：/displayVideo/front/info
     */
    @ApiOperation("前台获取是否展示视频详细信息")
    @GetMapping(value = "/front/info")
    public R<DisplayVideo> frontInfo(@RequestParam("id") Long id)
    {
        return R.ok(displayVideoService.selectDisplayVideoById(id));
    }

    /**
     * 新增是否展示视频
     * 接口路径：/displayVideo/front/add
     */
    @ApiOperation("前台新增是否展示视频")
    @PostMapping("/front/add")
    public AjaxResult frontAdd(@RequestBody DisplayVideo displayVideo)
    {
        return toAjax(displayVideoService.insertDisplayVideo(displayVideo));
    }

    /**
     * 修改是否展示视频
     * 接口路径：/displayVideo/front/edit
     */
    @ApiOperation("前台修改是否展示视频")
    @PostMapping("/front/edit")
    public AjaxResult frontEdit(@RequestBody DisplayVideo displayVideo)
    {
        return toAjax(displayVideoService.updateDisplayVideo(displayVideo));
    }

    /**
     * 删除是否展示视频
     * 接口路径：/displayVideo/front/delete
     */
    @ApiOperation("前台删除是否展示视频")
    @GetMapping("/front/delete")
    public AjaxResult frontRemove(@RequestParam Long[] ids)
    {
        return toAjax(displayVideoService.deleteDisplayVideoByIds(ids));
    }
}
